package com.acwing.www;

/**
 * Creared with IntelliJ IDEA.
 * Description:前缀和
 * User:yxd
 * Date:2022-01-11
 * Time:0:35
 */
import java.util.Scanner;
public class Prefix{
    static int N = 100010;
    static int[] a = new int[N];
    static int[] s = new int[N];
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int m = input.nextInt();
        for(int i = 1;i <= n;i ++){
            a[i] = input.nextInt();
        }
        //前缀和模板
        for(int j = 1;j <=  n;j ++){
            s[j ] = s[j - 1] +a[j];//前j项 的和
        }
        s[0] = 0;//处理边界问题
        while(m-- != 0){
            int l = input.nextInt();
            int r = input.nextInt();

            int h = s[r]  - s[l - 1];//r为右边界 l为左边界
            System.out.println(h);
        }
    }
}
